#!/usr/bin/php
<?php



require_once dirname(__FILE__)  . '/simple_helpers.inc';

$c_basic = array(
  // octal, legal or not
  '0123' => '',  
  '083' => '',
  '00' => '',
  '0' => '',
  // decimal
  '1' => '',
  '10' => '',
  '213' => '',
  // hex
  '0xaf' => '',
  '0x00' => '',
  '0xDEADBEEF' => '',
  '0xFF' => ''
);

$c_fractions = array(
  '17.97' => '',
  '17.97a' => 'a',
  '12.3F' => '',
  '12.3FT' => 'T',
  '12.3TF' => 'TF',  
  '.10' => '',
  '12E1' => '',
  '12e-10' => '',
  '12e-10e' => 'e'
);
  


// unsigned and longs
$ul = array();
foreach($c_basic as $i=>$o)
{
  $ul[$i . "u"] = $o;
  $ul[$i . "U"] = $o;
  $ul[$i . "l"] = $o;
  $ul[$i . "L"] = $o;
  $ul[$i . "ul"] = $o;
  $ul[$i . "Ul"] = $o;
  $ul[$i . "ul"] = $o;
  $ul[$i . "uL"] = $o;  
}

$c_ints = array_merge($c_basic, $ul);


$c_reals = array_merge($c_ints, $c_fractions);


$java = array('5.0' => '',
              '5d' => '',
              '-0.5' => '-',
              '10f' => '',
              '3.14159e0' => '',
              '2.718281828459045D' => '',
              '1.0e-6D' => ''
);

$python_nums = array(
  // floats
  "3.14" => '',
  "10." => '',
  ".001" => '',
  "1e100" => '',
  "3.14e-10" => '',
  "0e0" => '',
  '1.1j' => '',
  '1ji' => 'i',
  '3.14j' => '',
  '10.j' => '',
  '10j' => '',
  '.001j' => '',
  '1e100j' => '',
  '3.14e-10j' => '',
  '3.14-10j' => '-',
  '3.14-10lj' => '-j'
);


$langs = array('c' => $c_reals,
               'cs' => $c_reals,
               'java' => array_merge($c_reals, $java),
               'py' => array_merge($c_basic, $python_nums)
);
               
 
foreach($langs as $l=>$tests)
{
  foreach($tests as $i=>$o)
    test($l, $i, $o, '%(<NUMERIC>.*?</NUMERIC>)|(</?(?!NUMERIC).*?>)%', '');
}


exit($EXIT_STATUS);
